/**
 * 泛型的使用
 */

/**
 * 泛型方法
 * @template T
 * @param {T} a
 * @return {*}
 */
function add<T>(a: T) {
  return Text;
}

/* 泛型箭头函数 */
const func = <T>(a: T) => a;

class Person<T, U> {
  name: T;
  constructor(name: T) {
    this.name = name;
  }
  getName() {
    return this.name;
  }
}

// 泛型接口
interface P<T> {
  (arg: T): T;
}

const getValue = <T extends object, U extends keyof T>(obj: T, key: U): T[U] => obj[key];
const getValues = <T extends object, U extends keyof T>(obj: T, keys: U[]): T[U][] =>
  keys.map((key) => obj[key]);

const obj = { a: 1, b: 2 };
console.log(getValue(obj, 'a'));
console.log(getValues(obj, ['a', 'b']));
export const a = 12;
